Intro to Computers and Java

Why Program?

Computer Systems: Hardware and Software

CPU

Main Memory

Secondary Memory

Why Are SSDs Faster than HDDs?

Input Devices

Any data the computer collects from the outside world

Output Devices

Software

Operating Systems

Set of programs that manages the computer’s hardware devices and controls their processes.

Most modern OS are multitasking (multitasking !== parallel processing), or time sharing (can do more than one task over a given time period)

Application Software

Specialized environment for the user to work in.

This is the type of software we’ll be working with.

Programming Languages

Special language used to write computer programs

An algorithm is a set of well-defined sequential steps to completing a task.

A computer program is a set of instructions that enable the computer to solve a problem or perform a task

A computer needs the algorithm to be written in machine language, which is written using binary.

Procedural Programming

Older programming languages were procedural.

Object-Oriented Programming

Software Engineering

Encompasses the whole process of crafting computer software.

Software engineers use special software designed for testing programs.

Java History

1991:

What Is a Program Made Of?

Common conceptions:

Lines vs Statements

Variables

The Compiler and JVM

What is a Program Made Of? (cont.)

Java is both a compiled and interpreted language!

Portability

Java Editions

Different editions of the Java Development Kit:

Quick Reference: Compiling and Running Java Code

  1. Compile Source Code to Byte Code: javac <file.java>
  2. Run Byte Code: java <classname>

e.g., javac HelloWorld.java && java HelloWorld

The Programming Process

  1. Clearly define what the program should do.
  2. Visualize the program running on the computer.
  3. Use design tools to create a model of the program.
  4. Check the model for logical errors.
  5. Compiled the code
  6. Correct errors found during compilation (cycle between 5 and 6)
  7. ???

Types of Errors

  1. Compile Error: x = 2
  2. Run-Time Error: x = 2/0;
  3. Logical Error: grossPay = hours + payrate;